﻿var SIZE_RATIO = 0.8; //尺寸系数
var APPROPRIATE_SIZE = GetSize();
function newGuid() {
    var guid = "";
    for (var i = 1; i <= 32; i++) {
        var n = Math.floor(Math.random() * 16.0).toString(16);
        guid += n;
        if ((i == 8) || (i == 12) || (i == 16) || (i == 20))
            guid += "-";
    }
    return guid;
}
function notify(message, title, iconCls, timeout, x, y, width) {
    if (!message) { return; }
    if (!title) { title = "提示"; }
    if (!iconCls) { iconCls = "mini-messagebox-info"; }
    if (!timeout) { timeout = 2000; }
    if (!width) { width = 250; }
    if (!x) { x = "center"; }
    if (!y) { y = "center"; }
    var a = mini.showMessageBox({
        showModal: false,
        width: width,
        title: title,
        iconCls: iconCls,
        message: message,
        timeout: timeout,
        x: x,
        y: y
    });
    setTimeout(function () { mini.hideMessageBox(a); }, timeout);
}

function GetSize(ratio) {
    if (!ratio) { ratio = SIZE_RATIO; }
    var width = Math.round(screen.width * ratio);
    var height = Math.round(screen.height * ratio);
    return { Width: width, Height: height };
}

/*-表单窗体公共函数-*/
function CloseWindow(action) {
    if (action == "close" && form.isChanged()) {
        if (confirm("数据被修改了，是否先保存？")) {
            return false;
        }
    }
    console.log(window.CloseOwnerWindow);
    if (window.CloseOwnerWindow) {
        //alert("window.CloseOwnerWindow");
        return window.CloseOwnerWindow(action);
    }
    else {
        //alert("window.close");
        window.close();
    }
}
function onOk(e) {
    CloseWindow("ok");
}
function onCancel(e) {
    CloseWindow("cancel");
}

function writeStatusHtml() {
    document.write('    <div style="text-align: right;padding:3px;">        <div class="StatusTag Completed">            已完成        </div>        <div class="StatusTag Ignore">            非必要        </div>        <div class="StatusTag Working">            进行中        </div>        <div class="StatusTag Waiting">            未开始        </div>        <div class="StatusTag Timeout">            超目标工期        </div>    </div>');
}